package net.taviscaron.drivenotes.android.activity;

import net.taviscaron.drivenotes.android.R;
import net.taviscaron.drivenotes.shared.model.entity.Car;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class CarDetailsActivity extends Activity {
    private static final String CHARGING_ACTION = "net.taviscaron.drivenotes.android.CHARGING";
    private static final String SERVICE_ACTION = "net.taviscaron.drivenotes.android.SERVICE";
    private static final String STATISTIC_ACTION = "net.taviscaron.drivenotes.android.STATISTIC";
    private Car car;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.car_details);
        
        car = (Car)getIntent().getSerializableExtra("car");
        
        ((TextView)findViewById(R.id.carDetailsName)).setText(car.getBrand() + " " + car.getModel());
        ((TextView)findViewById(R.id.carDetailsDescription)).setText("");
        
        ((Button)findViewById(R.id.statisticButton)).setOnClickListener(new OnClickListener() {
	    public void onClick(View arg0) {
		statisticButtonClick();
	    }
	});
        
        ((Button)findViewById(R.id.chargingButton)).setOnClickListener(new OnClickListener() {
	    public void onClick(View arg0) {
		chargingButtonClick();
	    }
	});
        
        ((Button)findViewById(R.id.serviceButton)).setOnClickListener(new OnClickListener() {
	    public void onClick(View arg0) {
		serviceButtonClick();
	    }
	});
    }
    
    private void statisticButtonClick() {
	Intent intent = new Intent(STATISTIC_ACTION);
	intent.putExtra("car", car);
	startActivity(intent);
    }
    
    private void serviceButtonClick() {
	Intent intent = new Intent(SERVICE_ACTION);
	intent.putExtra("car", car);
	startActivity(intent);
    }
    
    private void chargingButtonClick() {
	Intent intent = new Intent(CHARGING_ACTION);
	intent.putExtra("car", car);
	startActivity(intent);
    }
}
